package com.example.mvvm.fragment;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.mvvm.BR;
import com.example.mvvm.R;
import com.example.mvvm.base.BaseFragment;
import com.example.mvvm.databinding.FragmentHomeBinding;
import com.example.mvvm.mode.TaskModel;
import com.example.mvvm.view.BallView2;
import com.example.mvvm.viewmodel.fragment.HomeViewModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Time: 5/6/2021 10:52
 * Author: TAO
 * Description:
 */
public class HomeFragment extends BaseFragment<HomeViewModel, FragmentHomeBinding> {

    public static HomeFragment newInstance() {
        HomeFragment homeFragment = new HomeFragment();
        Bundle args = new Bundle();
        homeFragment.setArguments(args);
        return homeFragment;
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_home;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        List<TaskModel> taskModels = new ArrayList<>();
        for (int i = 0; i < 23; i++) {
            TaskModel taskModel = new TaskModel();
            taskModel.setId("" + System.nanoTime());
            taskModel.setDifficultyLevel("1");
            taskModel.setName("测试" + i);
            taskModels.add(taskModel);
        }
        getBinging().homeBall.setData(taskModels);
        getBinging().homeBall.requestLayout();
        getBinging().homeBall.setBallViewListener(new BallView2.BallViewListener() {
            @Override
            public void getTaskId(String taskId) {

            }
        });
        //属性动画
        //ObjectAnimator parentAnimator = ObjectAnimator.ofInt(LayoutInflater.from(getActivity()).inflate(getLayoutId(),null), "backgroundColor", Color.parseColor("#ffb300"), Color.parseColor("#0000ff"));
        //parentAnimator.setEvaluator(new ArgbEvaluator());
        ////播放次数：循环
        //parentAnimator.setRepeatCount(-1);
        ////播放模式：循环播放时不是从头开始，从结尾开始
        //parentAnimator.setRepeatMode(ValueAnimator.REVERSE);
        ////播放时间5000ms
        //parentAnimator.setDuration(5000);
        ////播放动画
        //parentAnimator.start();
    }

    @Override
    public int variableId() {
        return BR.viewModel;
    }


}
